home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 February / Gamestar_81_2006-02_dvd.iso / Red Shark / Missions / Mission_12 / MissionTasks.script < prev    next >
Text File  |  2001-11-26  |  9KB  |  340 lines

  1. //-------------------------------------------------------------------
  2. //
  3. //  This code is copyright 2001 by G5 Software.
  4. //  Any unauthorized usage, either in part or in whole of this code
  5. //  is strictly prohibited. Violators WILL be prosecuted to the
  6. //  maximum extent allowed by law.
  7. //
  8. //-------------------------------------------------------------------
  9.  
  10. ///////////////////////////////////////
  11. //
  12. // Mission 12 -- Eliminate Partisans
  13. //
  14. ///////////////////////////////////////
  15. class CMission12_AIController extends CBaseAIController
  16. {
  17.   array  ActivatePointCenterList = array(
  18.     vector( 6622, 4148, 0 )     // Soviet Katusha Point of Fire
  19.     );    //
  20.  
  21.  
  22.   array  ActivatePointRadiusList = array(
  23.     100.0                       //
  24.     );
  25.  
  26.   array  ActivatePointNameList = array(
  27.     "A"
  28.     );
  29.  
  30.   void OnObjectEnterArea( int _AreaIndex, string _NavPointName, string _ObjectID)
  31.   {
  32.     if ( _AreaIndex == 0
  33.       && Core_IsStringStartsWith( _ObjectID, "12_SovietTank"))
  34.     {
  35.       Core_BroadcastEvent("OnSovietOffensiveStop");
  36.     }
  37.   }
  38. }
  39. //====================================================================================
  40. class C12_SovietAmmo extends C12_SovietKatusha
  41. {
  42.   vector   DestinationPoint        = vector( 6940, 4170, 0 );
  43.   string   LeaderName              = "SovietAmmo_Rank";
  44.  
  45.   void Init()
  46.   {
  47.     DestinationPoint = vector( 6940, 4170, 0 );
  48.     GiveOrder_MoveToTarget();
  49.   }
  50.  
  51. }
  52. //------------------------------------------------------------------------------------
  53. class C12_SovietKatusha extends CBaseAITask_BaseTask, CNavPointUser
  54.      //CNavPointUser, CBaseAITask_BaseTask
  55. {
  56.   //
  57.   // convoy parameters
  58.  
  59.   vector   DestinationPoint        = vector( 6644, 4124, 0 );//GetNavPoint("NavPoint_04"); // where to go
  60.   vector   FormationVector         = vector( 25, 0, 0);
  61.   vector   PointOfFire             = vector( 2100, 3485, 130 );
  62.   float    CruiserSpeed            = 29; // autocade with guard should keep this speed
  63.   float    RunSpeed                = 29; // autocade wo guards should keep this speed
  64.   float    OvertakeSpeed           = 32; // maximum allowed speed for overtake
  65.   float    AutocadDistanceMin      = 20; // nearest allowed distance in autocade
  66.   float    AutocadDistanceOptimum  = 25; // try to keep this distance in autocade
  67.   float    AutocadDistanceOvertake = 30; // overtake distance
  68.   float    DisperceRadius          = 60;
  69.   string   CurLeader               = "";
  70.   string   LeaderName              = "SovietOffensive_Rank";
  71.   boolean  IsLeader                = false;
  72.   boolean  OnTanksStops             = false;
  73.  
  74.   //
  75.   // current state
  76.  
  77.   boolean  Moving   = false; // true when object is moving to destination
  78.   boolean  Ambushed = false; // true when object is under ambush
  79.   boolean  Retreat  = false; // true when object is retreating
  80.   boolean  Run      = false; // true when object is running without stop to destination
  81.  
  82.   boolean MovingStatus = false;
  83.  
  84.   void OnStopped()
  85.     {
  86.     if( OnTanksStops )
  87.       {
  88.       string Leader = GetCommander(LeaderName);
  89.       if ( Leader != "" )
  90.         {
  91.         SetOrder_Formation(
  92.           Leader,
  93.           FormationVector,
  94.           10, //#TMP
  95.           15, //#TMP
  96.           OvertakeSpeed/2,
  97.           OvertakeSpeed/2);
  98.         }
  99.       }
  100.     }
  101.  
  102.   void OnSovietOffensiveStop()
  103.   {
  104.       OnTanksStops = true;
  105.   }
  106.   void ClearState()
  107.   {
  108.     Moving    = false;
  109.     Ambushed  = false;
  110.     Retreat   = false;
  111.     Run       = false;
  112.     CurLeader = "";
  113.     IsLeader  = false;
  114.   }
  115.   // start up initialization
  116.   void Init()
  117.   {
  118.     SetFireStyle_NoFire();
  119.     DestinationPoint = vector( 6644, 4124, 0 );
  120.     // give start order
  121.     GiveOrder_MoveToTarget();
  122.   }
  123. //  void OnEnemyTargeted()
  124. //  {
  125. //      GiveOrder_Disperse();
  126. //  }
  127.   void GiveOrder_Disperse()
  128.   {
  129.     // set state
  130.     ClearState();
  131.     Ambushed = true;
  132.     SetOrder_StopNow();
  133.         // move to random point
  134.         SetOrder_MoveTo(
  135.             GetNowPosition() + vector( rand(DisperceRadius), rand(DisperceRadius), 0.0),
  136.             OvertakeSpeed);
  137.   }
  138. //  void OnNoEnemy()
  139. //  {
  140. //    if ( !OnTanksStops )
  141. //      {
  142. //      GiveOrder_MoveToTarget();
  143. //      }
  144. //  }
  145.   void GiveOrder_MoveToTarget()
  146.   {
  147.     //Core_LogMessage("" + Core_GetIdentificator() + ": order: move to target");
  148.     string Leader = GetCommander(LeaderName); // find leader that we should followed by
  149.     if ( Moving == true
  150.       && Leader == CurLeader)
  151.     {
  152.       // nothing changed
  153.       return;
  154.     }
  155.     // set state
  156.     ClearState();
  157.     Moving = true;
  158.     CurLeader = Leader;
  159.     if ( Leader == "")
  160.     {
  161.       // we are leader. go directly to destination
  162.       SetOrder_MoveTo(
  163.         DestinationPoint,
  164.         CruiserSpeed);
  165.     }
  166.     else
  167.     {
  168.       // leader found. follow him
  169.       SetOrder_Follow(
  170.         Leader, // follow leader
  171.         AutocadDistanceMin,
  172.         AutocadDistanceOptimum,
  173.         AutocadDistanceOvertake,
  174.         CruiserSpeed,
  175.         OvertakeSpeed);
  176.     };
  177.   }
  178.   void OnLeaderLost( string _LeaderID)
  179.   {
  180.     // reorder
  181.     GiveOrder_MoveToTarget();
  182.   }
  183. }
  184. //===========================================================================================
  185. class C12_SovietDefender extends CBaseAITask_BaseTask, CNavPointUser
  186.      //CNavPointUser, CBaseAITask_BaseTask
  187. {
  188. }
  189. class C12_TraitorAA extends CBaseAITask_BaseTask, CNavPointUser
  190.      //CNavPointUser, CBaseAITask_BaseTask
  191. {
  192. }
  193. class C12_Traitor extends CBaseAITask_BaseTask, CNavPointUser
  194.      //CNavPointUser, CBaseAITask_BaseTask
  195. {
  196. }
  197. //============================================================================================
  198. class C12_GermanAA02 extends C12_GermanAA01
  199. {
  200.   vector   DestinationPoint        = vector( 6187, 6011, 0); // where to go
  201.   string   Ranking                 = "AA02_Rank";
  202. }
  203. //--------------------------------------------------------------------------------------------
  204. class C12_GermanAA01 extends CBaseAITask_BaseTask, CNavPointUser
  205. {
  206.   //
  207.   // convoy parameters
  208.  
  209.   vector   DestinationPoint        = vector( 6049, 5602, 0); // where to go
  210.   vector   FormationVector         = vector( 5, -90, 0);
  211.   float    CruiserSpeed            = 25; // autocade with guard should keep this speed
  212.   float    RunSpeed                = 25; // autocade wo guards should keep this speed
  213.   float    OvertakeSpeed           = 29; // maximum allowed speed for overtake
  214.   float    AutocadDistanceMin      = 20; // nearest allowed distance in autocade
  215.   float    AutocadDistanceOptimum  = 25; // try to keep this distance in autocade
  216.   float    AutocadDistanceOvertake = 30; // overtake distance
  217.   float    DisperceRadius          = 50;
  218.   string   CurLeader               = "";
  219.   string   Ranking                 = "AA01_Rank";
  220.   boolean  IsLeader                = false;
  221.   boolean  OnTanksStops            = false;
  222.  
  223.   //
  224.   // current state
  225.  
  226.   boolean  Moving   = false; // true when object is moving to destination
  227.   boolean  Ambushed = false; // true when object is under ambush
  228.   boolean  Retreat  = false; // true when object is retreating
  229.   boolean  Run      = false; // true when object is running without stop to destination
  230.  
  231.   boolean MovingStatus = false;
  232.  
  233.   void OnConvoySPlatoonStop()
  234.   {
  235.     if ( !OnTanksStops )
  236.       {
  237.         OnTanksStops = true;
  238.         SetOrder_Formation(
  239.           Leader,
  240.           FormationVector,
  241.           45, //#TMP
  242.           15, //#TMP
  243.           OvertakeSpeed/2,
  244.           OvertakeSpeed/2);
  245.       }
  246.   }
  247.  
  248.   void ClearState()
  249.   {
  250.     Moving    = false;
  251.     Ambushed  = false;
  252.     Retreat   = false;
  253.     Run       = false;
  254.     CurLeader = "";
  255.     IsLeader  = false;
  256.   }
  257.  
  258.   //
  259.   // start up initialization
  260.  
  261.   void Init()
  262.   {
  263.     SetFireStyle_Nearest();
  264.     // DestinationPoint = vector( 6049, , 0);
  265.     // give start order
  266.     GiveOrder_MoveToTarget();
  267.   }
  268.  
  269.   void OnEnemyTargeted()
  270.   {
  271.     string EnemyID = GetTargetedEnemy();
  272.     SetFireStyle_Enemy( EnemyID);
  273.     GiveOrder_Disperse();
  274.   }
  275.  
  276.   void GiveOrder_Disperse()
  277.   {
  278.     // set state
  279.     ClearState();
  280.     Ambushed = true;
  281.  
  282.     SetOrder_StopNow();
  283.  
  284.         // move to random point
  285.         SetOrder_MoveTo(
  286.             GetNowPosition() + vector( rand(DisperceRadius), rand(DisperceRadius), 0.0),
  287.             OvertakeSpeed);
  288.   }
  289.  
  290.   void OnNoEnemy()
  291.   {
  292.       GiveOrder_MoveToTarget();
  293.   }
  294.  
  295.   void GiveOrder_MoveToTarget()
  296.   {
  297.     //Core_LogMessage("" + Core_GetIdentificator() + ": order: move to target");
  298.  
  299.     string Leader = GetCommander(Ranking); // find leader that we should followed by
  300.     if ( Moving == true
  301.       && Leader == CurLeader)
  302.     {
  303.       // nothing changed
  304.       return;
  305.     }
  306.  
  307.     // set state
  308.     ClearState();
  309.     Moving = true;
  310.     CurLeader = Leader;
  311.  
  312.     if ( Leader == "")
  313.     {
  314.       // we are leader. go directly to destination
  315.       SetOrder_MoveTo(
  316.         DestinationPoint,
  317.         CruiserSpeed);
  318.     }
  319.     else
  320.     {
  321.       // leader found. follow him
  322.       SetOrder_Follow(
  323.         Leader, // follow leader
  324.         AutocadDistanceMin,
  325.         AutocadDistanceOptimum,
  326.         AutocadDistanceOvertake,
  327.         CruiserSpeed,
  328.         OvertakeSpeed);
  329.     };
  330.   }
  331.  
  332.   void OnLeaderLost( string _LeaderID)
  333.   {
  334.     // reorder
  335.     GiveOrder_MoveToTarget();
  336.   }
  337. };
  338.  
  339.  
  340.